﻿<#if workflows??>
    <#include "../../include/alfresco-macros.lib.ftl" />
    <#assign el=args.htmlid?js_string>
<script type="text/javascript">//<![CDATA[
new Alfresco.DocumentWorkflows("${el}").setOptions(
        {
            nodeRef: "${nodeRef?js_string}",
            siteId: <#if site??>"${site?js_string}"<#else>null</#if>,
            destination: "${destination}"
        }).setMessages(
${messages}
);
//]]></script>

<div id="${el}-body" class="document-workflows document-details-panel">
    <h2 id="${el}-heading" class="thin dark">
    ${msg("header.workflows")}
        <span class="alfresco-twister-actions">
			<a href="#" name=".onAssignWorkflowClick" class="${el} edit" title="${msg('label.assignWorkflow')}">&nbsp;</a>
			</span>
    </h2>

    <div class="panel-body">
        <div class="info">
            <#if workflows?size == 0>
				${msg("label.partOfNoWorkflows")}
			<#else>
            ${msg("label.partOfWorkflows")}
            </#if>
        </div>

        <hr/>
        <#if workflows?size &gt; 0>
            <div class="workflows">
                <#list workflows as workflow>
                    <div class="workflow <#if !workflow_has_next>workflow-last</#if>">
                        <a href="${siteURL("workflow-details?workflowId=" + workflow.id?js_string + "&nodeRef=" + (args.nodeRef!"")?js_string)}"><font size="4">${workflow.title?html}</font></a>
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width=50%>Inicijavo: </td>
                                <td width=50%><#if workflow.initiator.firstName?? && workflow.initiator.firstName?length &gt; 0 && workflow.initiator.lastName?? && workflow.initiator.lastName?length &gt; 0>${workflow.initiator.firstName?html} ${workflow.initiator.lastName?html}<#else>${workflow.initiator.userName?html}</#if></td>
                            </tr>
                            <tr>
                                <td width=50%>Inicijavimo data: </td>
                                <td width=50%><span class="Time">${workflow.startDate?date("yyyy-MM-dd'T'HH:mm:ss")?string("yyyy-MM-dd HH:mm:ss")}</span></td>
                            </tr>
                        </table>
                        <div class="clear"></div>
                    </div>
                </#list>
            </div>
        </#if>
        <br />
        <br />

        <div class="info">
            <#if workflowsHistory?size == 0>
				${msg("label.partOfNoWorkflowsHistory")}
			<#else>
            ${msg("label.partOfWorkflowsHistory")}
            </#if>
        </div>
        <hr/>

        <#if workflowsHistory?size &gt; 0>
            <div class="workflows">
                <#list workflowsHistory as workflow>
                    <div class="workflow <#if !workflow_has_next>workflow-last</#if>">
                        <a href="${siteURL("workflow-details?workflowId=" + workflow.id?js_string + "&nodeRef=" + (args.nodeRef!"")?js_string)}"><font size="4">${workflow.title?html}</font></a>
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width=50%>Inicijavo: </td>
                                <td width=50%><#if workflow.initiator.firstName?? && workflow.initiator.firstName?length &gt; 0 && workflow.initiator.lastName?? && workflow.initiator.lastName?length &gt; 0>${workflow.initiator.firstName?html} ${workflow.initiator.lastName?html}<#else>${workflow.initiator.userName?html}</#if></td>
                            </tr>
                            <tr>
                                <td width=50%>Inicijavimo data: </td>
                                <td width=50%><span class="Time">${workflow.startDate?date("yyyy-MM-dd'T'HH:mm:ss")?string("yyyy-MM-dd HH:mm:ss")}</span></td>
                            </tr>
                            <tr>
                                <td width=50%>Įvykdymo data: </td>
                                <td width=50%><span class="Time">${workflow.endDate?date("yyyy-MM-dd'T'HH:mm:ss")?string("yyyy-MM-dd HH:mm:ss")}</span></td>
                            </tr>
                        </table>
                        <div class="clear"></div>
                    </div>
                </#list>
            </div>
        </#if>
    </div>

    <script type="text/javascript">//<![CDATA[
    Alfresco.util.createTwister("${el}-heading", "DocumentWorkflows");
    //]]></script>
</div>
</#if>